
<div id="container" class="clear">
	<div id="left">
		<?php if(Session::instance()->get('userId')){ if($saved){ 
			echo <<<EOT
		<p class="fr mt15" id="fav"><a class="removeFav" href="#">取消收藏</a></p>
EOT;
		}else{ 
			echo <<<EOT
		<p class="fr mt15" id="fav"><a class="addFav" href="#">加入收藏</a></p>
EOT;
		}
		}
?>
		<h1><?php echo $code['title']; ?></h1>
		
		<?php if(!empty($code['intro'])){ ?><p class="intro"><?php echo $code['intro']; ?></p><?php } ?> 
		
		<pre class="brush: <?php echo $code['brushLan']; ?>;">
<?php echo html::specialchars($snippet['snippet']);  ?>
		</pre>
		<!--<p class="mt10"><a href="#" class="tag mr10">Date</a><a href="#" class="tag">时间</a></p>-->


		<h2 class="mt50">评论</h2>
		<?php foreach($cmts as $cmt){ ?>
		<div class="p5 bgf4 mt10 mb10 clear"><p class="fr pt3"><?php echo date::get_latest_timespan(date::timespan($cmt->pubdate));?></p><img class="fl mr5" src="<?php echo gravatar::get($cmt->user->email); ?>" width="24" height="24" /><p class="pt3"><a href="<?php echo url::site('user/view/'.$cmt->user->id); ?>"><?php echo $cmt->user->username; ?></a></p></div>
		<div class="fc444 cmt"><?php echo $cmt->content; ?></div>
		<?php } ?>


<?php if(user::is_login()){ ?>
		<form action="<?php echo url::site('user/addcmt'); ?>" method="post">
		<p class="mt50"><textarea name="cmt_content" id="cmt" cols="80" rows="10">评论内容</textarea></p>
		<input type="hidden" name="code_id" value="<?php echo $code['id']; ?>" />
		<input type="hidden" name='brush' value="<?php echo $code['brushLan']; ?>" />
		<p><input type="submit" name="" value="提交评论" /></p>
		</form>
<?php } else { ?>
		<p><a href="<?php echo url::site('user/login'); ?>">登陆</a>后方可发表评论</p>
<?php } ?>
	</div>

	<div id="right">
		<div class="clear mb10 bgf4 p5">
		<img src="<?php echo gravatar::get($user['email']);  ?>" width="24" height="24" />
		<a href="<?php echo url::site('user/view/'.$user['id']); ?>" class="mr5"><?php echo $user['username'];?></a><span class="gray"><?php echo date::get_latest_timespan(date::timespan($snippet['pubdate'])); ?>发布</span>
		<p class="pt15">修改记录：<?php for($i=0;$i<$snippetLength;$i++){if($i==$currentR-1) echo 'r'.($i+1).' '; else echo '<a href="'.url::site('code/detail/'.$code['id'].'/'.($i+1)).'">r'.($i+1).'</a> ';} ?></p>
		<p class="">收藏人数：<?php echo $savedNum; ?></p>
		<?php if(!empty($code['link'])){ ?>
		<p class="">参考链接：<a target="_blank" href="<?php echo $code['link']; ?>"><?php echo text::limit_chars($code['link'],20,'...'); ?></a></p>
		<?php } ?>
		<p class="">语言类别：<a href="<?php echo url::site('code/lan/'.$code['lan']); ?>"><?php echo $code['lan']; ?></a></p>
		<?php if(Session::instance()->get('userId') == $code['user_id']){ ?>
		<p class="pt10"><a href="<?php echo url::site('user/editcode/'.$code['id']); ?>">编辑</a></p>
		<?php } ?>
		</div>
		<div class="clear"></div>
		
		<?php if(count($codeList)){ ?>
		<p class="bdotted pb5 mb5 fs14 mt20"><?php echo $user['username'];?>发布的其他代码</p>
		<ul>
			<?php foreach($codeList as $val){ ?>
			<li class="mb5">
			<p><a href="<?php echo url::site('code/detail/'.$val->id); ?>"><?php echo $val->title; ?></a></p>
			</li>
			<?php } ?>
		</ul>
		<?php if(count($codeList)>5){ ?><p class="fr"><a href="<?php echo url::site('user/codelist/'.$user['id']); ?>">查看更多 »</a></p><?php } ?>
		<?php } ?>
		
	</div>
</div>
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = '<?php echo url::base(); ?>media/script/syntax/clipboard.swf';
SyntaxHighlighter.all();

$('#fav').data('addFav','<a class="addFav" href="#">添加收藏</a>');
$('#fav').data('removeFav','<a class="removeFav" href="#">取消收藏</a>');
$('#fav').data('loading','<?php echo url::base();?>media/img/loading.gif');
$('#fav').data('ajaxUrl','<?php echo url::site('user/fav/'.$code['id']); ?>')

</script>

